package com.example.javabasic.suanfa.剑指offer.替换空格;

/**
 * @description
 * @Author Lin FuYuan
 * @date 2021/7/5
 */
public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param s string字符串
     * @return string字符串
     */
    public String replaceSpace (String s) {
        // write code here
        String x = "%20";
        StringBuilder builder = new StringBuilder();
        char[] chars = s.toCharArray();
        for (char aChar : chars) {
            builder.append(aChar == ' '?x:aChar);
        }
        return builder.toString();


    }
}
